from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Appointment',
            fields=[
                ('id', models.BigIntegerField(editable=False, primary_key=True, serialize=False)),
                ('patient_id', models.IntegerField(verbose_name='患者ID')),
                ('doctor_id', models.IntegerField(verbose_name='医生ID')),
                ('doctor_name', models.CharField(max_length=50, verbose_name='医生姓名')),
                ('doctor_title', models.CharField(max_length=50, verbose_name='医生职称')),
                ('hospital_name', models.CharField(max_length=100, verbose_name='医院名称')),
                ('hospital_address', models.CharField(max_length=255, verbose_name='医院地址')),
                ('department', models.CharField(max_length=50, verbose_name='科室')),
                ('appointment_date', models.DateField(verbose_name='预约日期')),
                ('appointment_weekday', models.CharField(max_length=10, verbose_name='星期')),
                ('time_slot', models.CharField(max_length=20, verbose_name='时间段')),
                ('fee', models.CharField(max_length=20, verbose_name='费用')),
                ('status', models.CharField(choices=[('pending', '待确认'), ('confirmed', '已确认'), ('canceled', '已取消'), ('completed', '已完成')], default='pending', max_length=20, verbose_name='状态')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
            ],
            options={
                'verbose_name': '预约信息',
                'verbose_name_plural': '预约信息',
                'db_table': 'reservation_appointment',
            },
        ),
        migrations.RunSQL(
            """
            CREATE TABLE IF NOT EXISTS reservation_order_0 (
                id BIGINT PRIMARY KEY,
                order_number VARCHAR(50) NOT NULL UNIQUE,
                patient_id INT NOT NULL,
                doctor_id INT NOT NULL,
                appointment_id BIGINT NOT NULL,
                amount DECIMAL(10, 2) NOT NULL,
                status VARCHAR(20) NOT NULL,
                payment_method VARCHAR(20),
                payment_time DATETIME NULL,
                created_at DATETIME NOT NULL,
                updated_at DATETIME NOT NULL
            );
            """,
            "DROP TABLE IF EXISTS reservation_order_0;"
        ),
        migrations.RunSQL(
            """
            CREATE TABLE IF NOT EXISTS reservation_order_1 (
                id BIGINT PRIMARY KEY,
                order_number VARCHAR(50) NOT NULL UNIQUE,
                patient_id INT NOT NULL,
                doctor_id INT NOT NULL,
                appointment_id BIGINT NOT NULL,
                amount DECIMAL(10, 2) NOT NULL,
                status VARCHAR(20) NOT NULL,
                payment_method VARCHAR(20),
                payment_time DATETIME NULL,
                created_at DATETIME NOT NULL,
                updated_at DATETIME NOT NULL
            );
            """,
            "DROP TABLE IF EXISTS reservation_order_1;"
        ),
        migrations.RunSQL(
            """
            CREATE TABLE IF NOT EXISTS reservation_order_2 (
                id BIGINT PRIMARY KEY,
                order_number VARCHAR(50) NOT NULL UNIQUE,
                patient_id INT NOT NULL,
                doctor_id INT NOT NULL,
                appointment_id BIGINT NOT NULL,
                amount DECIMAL(10, 2) NOT NULL,
                status VARCHAR(20) NOT NULL,
                payment_method VARCHAR(20),
                payment_time DATETIME NULL,
                created_at DATETIME NOT NULL,
                updated_at DATETIME NOT NULL
            );
            """,
            "DROP TABLE IF EXISTS reservation_order_2;"
        ),
    ]